
clear

cd "D:\data_replication"


// Import list of all product_ids
//------------------------------------------------------------------------------

use estimation\2_product_list\output\product_id_all.dta, clear


// Create dummy that indicates that the product is non-8-digit pc8plus
//------------------------------------------------------------------------------

gen pc_sub = length(pc)
gen non_pc8plus = 0
replace non_pc8plus = 1 if product_id > 3817
replace non_pc8plus = 1 if pc_sub == 2
replace non_pc8plus = 1 if pc_sub == 3
replace non_pc8plus = 1 if pc_sub == 4
replace non_pc8plus = 1 if pc_sub == 5

gen synthetic = strpos(pc, ".")
replace non_pc8plus = 1 if pc_sub == 6 & synthetic == 0
replace non_pc8plus = 1 if pc_sub == 7 & synthetic == 0


// Format and save
//------------------------------------------------------------------------------

sort product_id
by product_id: keep if _n == 1

keep pc product_id non_pc8plus

rename pc pc8plus 
rename product_id id

export delimited using estimation\4_demand_estimation\4_cobb_douglas_weights\id_to_pc8plus.csv, replace

